package com.ybear.ybmediax.audio;

import android.media.AudioTrack;

public class Config {
    //流类型
    @StreamType
    private int streamType = StreamType.STREAM_MUSIC;
    //采样率
    @RateInHzType
    private int sampleRateInHz = RateInHzType.RATE_8000;
    //声道
    @ChannelType
    private int channelConfig = ChannelType.CHANNEL_OUT_STEREO;
    //比特位
    @EncodingType
    private int encoding = EncodingType.ENCODING_PCM_16BIT;

    private Config() {}
    public static Config newConfig() { return new Config(); }

    @StreamType
    public int getStreamType() { return streamType; }
    public Config setStreamType(@StreamType int streamType) {
        this.streamType = streamType;
        return this;
    }

    @RateInHzType
    public int getSampleRateInHz() { return sampleRateInHz; }
    public Config setSampleRateInHz(@RateInHzType int sampleRateInHz) {
        this.sampleRateInHz = sampleRateInHz;
        return this;
    }

    @ChannelType
    public int getChannelConfig() { return channelConfig; }
    public Config setChannelConfig(@ChannelType int channelConfig) {
        this.channelConfig = channelConfig;
        return this;
    }

    @EncodingType
    public int getEncoding() { return encoding; }
    public Config setEncoding(@EncodingType int encoding) {
        this.encoding = encoding;
        return this;
    }

    public int getMinBufferSize() {
        return AudioTrack.getMinBufferSize( sampleRateInHz, channelConfig, encoding );
    }
}